import Vue from 'vue'
import Router from 'vue-router'

// import {
//   getChildrenPath
// } from '@/router/indexUtil'

Vue.use(Router)

const routes = [{
  path: '/',
  meta: {
    auth: false
  },
  name: 'login',
  component: () => import('../views/user/login.vue')
}, ]

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

// //使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
// router.beforeEach((to, from, next) => {
//   if (to.path === '/') {
//     next();
//   } else {
//     let token = localStorage.getItem('authorizationpms')
//     if (token === undefined || token === null || token === '') {
//       next('/');
//     } else {
//       next();

//       //// 从数据库取权限集合时，如果刷新会清空路由，需要在路由守卫中再绑定一次路由
//       // getChildrenPath('...');

//     }
//   }
// });

export default router
